<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>周消费榜信息</title>
<link type="text/css" rel="stylesheet" href="/css/style_old.css" />
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
</head>

<body>
	<table class="weeklyList_1" id="room">
 	</table>
</body>
<script type="text/javascript">
function request(paras){ 
	var url = location.href; 
	var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
	var paraObj = {} 
	for (i=0; j=paraString[i]; i++){ 
		paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
	} 
	var returnValue = paraObj[paras.toLowerCase()]; 
	if(typeof(returnValue)=="undefined"){ 
		return ""; 
	}else{ 
		return returnValue; 
	} 
}
function getRealLength(str) {
	var totalLength = 0;
	for (var i=0;i<str.length;i++){
		var charCode=str.charCodeAt(i);
		if (charCode>=0&&charCode<=128) {
			totalLength+=1;
		}else {
			totalLength+=2;
		}
	}
	return totalLength;
}
function getNickName(str){
	var length=getRealLength(str);	
	if(length>12){		
		var totalLength=0;	
		for (var i=0;i<str.length;i++){
			var charCode=str.charCodeAt(i);
			if (charCode>=0&&charCode<=128) {
				totalLength+=1;
			}else {
				totalLength+=2;					
			}
									
			if(totalLength>12){
				return str.substring(0,i);
			}else if(totalLength==12){
				return str.substring(0,i+1);
			}			 	
			
		}
		
	}
	return str;	
}


function getfav(){
	var roomId=request("roomid");
	try{
	$.ajax({
	  //使用get方法访问后台̨
	   type: "get",
	   //返回json格式的数据
	   dataType: "json",
	   //要访问的后台地址ַ
	   url:"/top!queryZhouInfo.jspa?roomId="+roomId+"&r="+Math.random(),
	  //data为返回的数据，在这里做数据绑定
	  complete : function (data, textStatus){
	       if (textStatus=="error") return;
		    //转换为json对象
		   try{
		   var dataObj=eval("("+data.responseText+")");
		   if(dataObj.flag==1){
		        var tempdiv = "";
		        //alert(dataObj.content);
		        if(dataObj.content!=null&&dataObj.content!=""){	
		        	// alert(dataObj.content);		        
			   		$.each(dataObj.content,function(i,item){
			   		     if(i<=2){			   		    	
			   		    	 var img='';
			   		    	 if(item.userFlag>0){
			   		    	 	img='<img src="images/'+item.userFlag+'.gif" />';
			   		    	 }			   		    	
			   		    	 var amount=item.amount+"";
			   		    	 var len=amount.length;
			   		    	 if(len>9){
			   		    	 	amount=amount.substring(len-9,len)+".0";
			   		    	 }else{
			   		    	 	amount+=".0";
			   		    	 }			   		    	
			   		    	tempdiv+='<tr><td class="td1">'+(i+1)+'.</td><td class="td2">'+img+'</td><td class="td3"><a title="'+item.nickName+'('+item.userId+')" >'+getNickName(item.nickName)+'</a></td><td class="td4"><img src="images/wk_icon2.jpg" /></td><td class="td5"><span>'+amount+'</span></td></tr>';			   		    	 
							//tempdiv = tempdiv + '<li><span>'+(i+1)+'.</span>'+img+'<a title="'+item.nickName+'('+item.userId+')" href="#">'+getNickName(item.nickName)+'</a><div class="noImg2"><img src="images/wk_icon2.jpg" /></div><span>'+amount+'</span></li>';
						 }
					});
					$('#room').html(tempdiv);
				}
		   }else{
		   		$('#room').html('<li>获取失败</li>');
		   }
		}catch(err)
		  {
	     	   return;
		  }
	   }
   });
   }catch(err)
		  {
	     	   return;
		  }
}
setInterval("getfav()",20000);
try{
 $('#room').html();
 getfav();
 
}catch(err)
		  {
		  }

</script>
</html>